home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
c4
/
pro2
/
1n06038b
< prev
next >
Wrap
Text File
|
1990-10-01
|
838b
|
59 lines
Listing 3
uses
scan;
var
tc : token_code;
function expr(var e : integer) : boolean;
var
op : token_code;
begin
expr := FALSE;
if tc <> TC_INT then
exit;
e := int_value;
tc := get_token;
while tc in [TC_ADD, TC_SUB, TC_MUL, TC_DIV] do
begin
op := tc;
tc := get_token;
if tc <> TC_INT then
exit;
case op of
TC_ADD:
e := e + int_value;
TC_SUB:
e := e - int_value;
TC_MUL:
e := e * int_value;
TC_DIV:
e := e div int_value;
end;
tc := get_token;
end;
expr := TRUE;
end;
var
result : integer;
begin
start_scan;
tc := get_token;
while tc <> TC_EOF do
begin
if expr(result) and (tc = TC_EOL) then
writeln('= ', result)
else
begin
writeln('*** ERROR ***');
restart_scan;
end;
tc := get_token;
end;
end.